<?php 
namespace App\Http\Controllers\Home;
use Session;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Home\ThrottlesLogins;
use Illuminate\Foundation\Home\AuthenticatesAndRegistersUsers;


header("content-type:text/html;charset=utf-8");
class IndexController extends Controller{
	public $model=false;
	public function __construct(){
	     $this->model = new \App\Index_Home();
	     
	}
	public function index(){
		//前台分类导航
		if(Session::has('category')){
		    $category = Session::get('category');
		}else{
		    $category=$this->model->select();
		    session::put('category',$category);
		}

        //前台轮播图
		$res = $this->model->home_select();
		//前台热销品牌
		$brand_hot	=$this->model->hot_brand();
		$brand_hot = array_map('get_object_vars', $brand_hot);
		//友情链接
		if(Session::has('link')){
		     $link = Session::get('link');
		 }else{		 	
		    $link=$this->model->friend_links();
		     Session::put('link',$link); 
		}

		//前台广告位1楼
		$adv1 = $this->model->adv1();
		if($adv1 == null){
			$a1 = 1;
		}else{
			$a1 = $adv1;
		}
		//前台广告位2楼
		$adv2 = $this->model->adv2();
		if($adv2 == null){
			$a2 = 2;
		}else{
			$a2 = $adv2;
		}
		//前台广告位3楼
		$adv3 = $this->model->adv3();
		if($adv3 == null){
			$a3 = 2;
		}else{
			$a3 = $adv3;
		}
		
		//显示搜索框下的关键词
		$hot_search_terms = $this->model->hot_search_terms();

		//热门商品
		$hot_goods = $this->model->hot_goods();

		//猜你喜欢
		$like_goods = $this->model->like_goods();

		//前台楼层1楼 智能手机 ID ：3
		if(Session::has('floor1')){
		     $floor1 = Session::get('floor1');
		 }else{		 	
		   	 $floor1=$this->model->floor1();
		     Session::put('floor1',$floor1); 
		}

		//前台楼层2楼 女装 ID ：28
		if(Session::has('floor2')){
		     $floor2 = Session::get('floor2');
		 }else{		 	
		   	 $floor2=$this->model->floor2();
		     Session::put('floor2',$floor2); 
		}

		//前台楼层3楼 食品 ID ：8,
		if(Session::has('floor3')){
		     $floor3 = Session::get('floor3');
		 }else{		 	
		   	 $floor3=$this->model->floor3();
		     Session::put('floor3',$floor3); 
		}

		return view('Home/Index',["photo"=>$res,'ak'=>$category,'brand_hot'=>$brand_hot,'link'=>$link,'adv1'=>$a1,'adv2'=>$a2,'adv3'=>$a3,'floor1'=>$floor1,'floor2'=>$floor2,'floor3'=>$floor3,'hot_search_terms'=>$hot_search_terms,'hot_goods'=>$hot_goods,'like_goods'=>$like_goods]);

		
	}
}

 ?>